<template>
    <div id="myChart" ref="myChart" :style="{width: '400px', height:'400px'}"></div>
</template>

<script>
    import echarts from 'echarts'

    export default {
        data() {
            return {
                xAxisData: [],
                seriesData: []
            }
        },
        props: {
            xAxisData: [],
            seriesData: []
        },
        mounted() {
            this.createCharts()
        },
        methods: {
            createCharts() {
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(this.$refs.myChart);
                // 绘制图表
                myChart.setOption({
                    title: {
                        text: 'ECharts 入门示例'
                    },
                    xAxis: {
                        type: 'category',
                        boundaryGap: false,
                        data: this.xAxisData
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [{
                        type: 'line',
                        data: this.seriesData,
                        areaStyle: {}
                    }]
                });
            }
        }
    }
</script>

<style scoped>

</style>